import checkPermission from '@/utils/permission'
const permission = {
  inserted(el, binding) {
    const { value } = binding
    if (!checkPermission(value)) el.parentNode && el.parentNode.removeChild(el)
  },
  update(el, binding) {
    const { value } = binding
    if (!checkPermission(value)) el.parentNode && el.parentNode.removeChild(el)
  },
}
const install = function(Vue) {
  Vue.directive('permission', permission)
}

if (window.Vue) {
  window['permission'] = permission
  Vue.use(install)
}

permission.install = install
export default permission
